Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
78742956
Kaydet (Commit)
78742956
authored
Tem 29, 2013
tarafından
Michael Meeks
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
liblo - add ability to select filter / format for saveas.
Change-Id: I866c6cb836407019973559051c854d24f9549d2a
üst
136f3bb1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
96 additions
and
7 deletions
+96
-7
liblibreoffice.hxx
desktop/inc/liblibreoffice.hxx
+2
-1
init.cxx
desktop/source/lib/init.cxx
+89
-4
libtest.cxx
smoketest/libtest.cxx
+5
-2
No files found.
desktop/inc/liblibreoffice.hxx
Dosyayı görüntüle @
78742956
...
...
@@ -15,7 +15,8 @@ class LODocument
public
:
virtual
~
LODocument
()
{}
virtual
bool
saveAs
(
const
char
*
url
)
=
0
;
// Save as the given format, if format is NULL sniff from ext'n
virtual
bool
saveAs
(
const
char
*
url
,
const
char
*
format
=
NULL
)
=
0
;
};
class
LibLibreOffice
...
...
desktop/source/lib/init.cxx
Dosyayı görüntüle @
78742956
...
...
@@ -43,6 +43,59 @@ class LibLibreOffice_Impl;
static
LibLibreOffice_Impl
*
gImpl
=
NULL
;
typedef
struct
{
const
char
*
extn
;
const
char
*
filterName
;
}
ExtensionMap
;
static
const
ExtensionMap
aWriterExtensionMap
[]
=
{
{
"doc"
,
"MS Word 97"
},
{
"docx"
,
"MS Word 2007 XML"
},
{
"fodt"
,
"OpenDocument Text Flat XML"
},
{
"html"
,
"HTML (StarWriter)"
},
{
"odt"
,
"writer8"
},
{
"ott"
,
"writer8_template"
},
{
"pdf"
,
"writer_pdf_Export"
},
{
"txt"
,
"Text"
},
{
"xhtml"
,
"XHTML Writer File"
},
{
NULL
,
NULL
}
};
static
const
ExtensionMap
aCalcExtensionMap
[]
=
{
{
"csv"
,
"Text - txt - csv (StarCalc)"
},
{
"fods"
,
"OpenDocument Spreadsheet Flat XML"
},
{
"html"
,
"HTML (StarCalc)"
},
{
"ods"
,
"calc8"
},
{
"ots"
,
"calc8_template"
},
{
"pdf"
,
"calc_pdf_Export"
},
{
"xhtml"
,
"XHTML Calc File"
},
{
"xls"
,
"MS Excel 97"
},
{
"xlsx"
,
"Calc MS Excel 2007 XML"
},
{
NULL
,
NULL
}
};
static
const
ExtensionMap
aImpressExtensionMap
[]
=
{
{
"fodp"
,
"OpenDocument Presentation Flat XML"
},
{
"html"
,
"impress_html_Export"
},
{
"odg"
,
"impress8_draw"
},
{
"odp"
,
"impress8"
},
{
"otp"
,
"impress8_template"
},
{
"pdf"
,
"impress_pdf_Export"
},
{
"potm"
,
"Impress MS PowerPoint 2007 XML Template"
},
{
"pot"
,
"MS PowerPoint 97 Vorlage"
},
{
"pptx"
,
"Impress MS PowerPoint 2007 XML"
},
{
"pps"
,
"MS PowerPoint 97 Autoplay"
},
{
"ppt"
,
"MS PowerPoint 97"
},
{
"svg"
,
"impress_svg_Export"
},
{
"swf"
,
"impress_flash_Export"
},
{
"xhtml"
,
"XHTML Impress File"
},
{
NULL
,
NULL
}
};
class
LibLODocument_Impl
:
public
LODocument
{
uno
::
Reference
<
css
::
lang
::
XComponent
>
mxComponent
;
...
...
@@ -50,7 +103,7 @@ public:
LibLODocument_Impl
(
const
uno
::
Reference
<
css
::
lang
::
XComponent
>
&
xComponent
)
:
mxComponent
(
xComponent
)
{
}
virtual
bool
saveAs
(
const
char
*
url
);
virtual
bool
saveAs
(
const
char
*
url
,
const
char
*
format
);
};
class
LibLibreOffice_Impl
:
public
LibLibreOffice
...
...
@@ -109,20 +162,52 @@ LibLibreOffice_Impl::documentLoad( const char *docUrl )
return
NULL
;
}
bool
LibLODocument_Impl
::
saveAs
(
const
char
*
url
)
bool
LibLODocument_Impl
::
saveAs
(
const
char
*
url
,
const
char
*
format
)
{
OUString
sURL
=
getUString
(
url
);
OUString
sFormat
=
getUString
(
format
);
try
{
uno
::
Reference
<
frame
::
XModel
>
xDocument
(
mxComponent
,
uno
::
UNO_QUERY_THROW
);
uno
::
Sequence
<
beans
::
PropertyValue
>
aSeq
=
xDocument
->
getArgs
();
OUString
aFilterName
;
OUString
aFilterName
,
aDocumentService
;
for
(
sal_Int32
i
=
0
;
i
<
aSeq
.
getLength
();
++
i
)
{
if
(
aSeq
[
i
].
Name
==
"FilterName"
)
aSeq
[
i
].
Value
>>=
aFilterName
;
else
if
(
aSeq
[
i
].
Name
==
"DocumentService"
)
aSeq
[
i
].
Value
>>=
aDocumentService
;
OUString
aValue
;
aSeq
[
i
].
Value
>>=
aValue
;
}
if
(
aDocumentService
==
""
)
{
gImpl
->
maLastExceptionMsg
=
"Unknown document type"
;
return
false
;
}
const
ExtensionMap
*
pMap
;
if
(
aDocumentService
==
"com.sun.star.sheet.SpreadsheetDocument"
)
pMap
=
(
const
ExtensionMap
*
)
aCalcExtensionMap
;
else
if
(
aDocumentService
==
"com.sun.star.presentation.PresentationDocument"
)
pMap
=
(
const
ExtensionMap
*
)
aImpressExtensionMap
;
else
// for the sake of argument only writer documents ...
pMap
=
(
const
ExtensionMap
*
)
aWriterExtensionMap
;
if
(
format
)
{
for
(
sal_Int32
i
=
0
;
pMap
[
i
].
extn
;
i
++
)
{
if
(
sFormat
.
equalsIgnoreAsciiCaseAscii
(
pMap
[
i
].
extn
)
)
{
aFilterName
=
getUString
(
pMap
[
i
].
filterName
);
break
;
}
}
}
aSeq
.
realloc
(
2
);
aSeq
[
0
].
Name
=
"Overwrite"
;
aSeq
[
0
].
Value
<<=
sal_True
;
...
...
@@ -130,7 +215,7 @@ bool LibLODocument_Impl::saveAs (const char *url)
aSeq
[
1
].
Value
<<=
aFilterName
;
uno
::
Reference
<
frame
::
XStorable
>
xStorable
(
mxComponent
,
uno
::
UNO_QUERY_THROW
);
xStorable
->
store
As
URL
(
sURL
,
aSeq
);
xStorable
->
store
To
URL
(
sURL
,
aSeq
);
return
true
;
}
catch
(
const
uno
::
Exception
&
ex
)
{
...
...
smoketest/libtest.cxx
Dosyayı görüntüle @
78742956
...
...
@@ -38,8 +38,11 @@ int main (int argc, char **argv)
if
(
argc
>
3
)
{
fprintf
(
stderr
,
"save document as '%s'
\n
"
,
argv
[
3
]
);
if
(
!
pDocument
->
saveAs
(
argv
[
3
]
)
)
const
char
*
pFilter
=
NULL
;
if
(
argc
>
4
)
pFilter
=
argv
[
4
];
fprintf
(
stderr
,
"save document as '%s' (%s)
\n
"
,
argv
[
3
],
pFilter
?
pFilter
:
"<null>"
);
if
(
!
pDocument
->
saveAs
(
argv
[
3
],
pFilter
)
)
{
char
*
pError
=
pOffice
->
getError
();
fprintf
(
stderr
,
"failed to save document '%s'
\n
"
,
pError
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment