LibreOffice Module sd (master) 1
sdcgmfilter.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <memory>
21#include <filter/importcgm.hxx>
22#include <tools/urlobj.hxx>
24#include <sfx2/docfile.hxx>
25#include <svx/xflclit.hxx>
26#include <svx/xfillit0.hxx>
27
28#include <sddll.hxx>
29#include <sdpage.hxx>
30#include <drawdoc.hxx>
31#include <sdcgmfilter.hxx>
32
33#include <DrawDocShell.hxx>
34
35using namespace ::com::sun::star;
36using namespace ::com::sun::star::uno;
37using namespace ::com::sun::star::task;
38using namespace ::com::sun::star::frame;
39
41 SdFilter( rMedium, rDocShell )
42{
43}
44
46{
47}
48
50{
51 bool bRet = false;
52
53 if (mxModel.is())
54 {
56 sal_uInt32 nRetValue;
57
58 if( mrDocument.GetPageCount() == 0 )
60
62 std::unique_ptr<SvStream> xIn(::utl::UcbStreamHelper::CreateStream(aFileURL, StreamMode::READ));
63 nRetValue = xIn ? ImportCGM(*xIn, mxModel, mxStatusIndicator) : 0;
64
65 if( nRetValue )
66 {
67 bRet = true;
68
69 if( ( nRetValue &~0xff000000 ) != 0xffffff ) // maybe the backgroundcolor is already white
70 { // so we must not set a master page
73
74 if(pSdPage)
75 {
76 // set PageFill to given color
77 const Color aColor(static_cast<sal_uInt8>(nRetValue >> 16), static_cast<sal_uInt8>(nRetValue >> 8), static_cast<sal_uInt8>(nRetValue >> 16));
78 pSdPage->getSdrPageProperties().PutItem(XFillColorItem(OUString(), aColor));
79 pSdPage->getSdrPageProperties().PutItem(XFillStyleItem(drawing::FillStyle_SOLID));
80 }
81 }
82 }
83 }
84 return bRet;
85}
86
88{
89 // No ExportCGM function exists(!)
90 return false;
91}
92
93extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportCGM(SvStream &rStream)
94{
96
97 ::sd::DrawDocShellRef xDocShRef = new ::sd::DrawDocShell(SfxObjectCreateMode::EMBEDDED, false, DocumentType::Impress);
98
99 xDocShRef->GetDoc()->EnableUndo(false);
100 bool bRet = ImportCGM(rStream, xDocShRef->GetModel(), css::uno::Reference<css::task::XStatusIndicator>()) == 0;
101
102 xDocShRef->DoClose();
103
104 return bRet;
105}
106
107/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
FILTER_DLLPUBLIC sal_uInt32 ImportCGM(SvStream &rIn, uno::Reference< frame::XModel > const &rXModel, css::uno::Reference< css::task::XStatusIndicator > const &aXStatInd)
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
bool Import()
Definition: sdcgmfilter.cxx:49
bool Export() override
Definition: sdcgmfilter.cxx:87
SdCGMFilter(SfxMedium &rMedium, ::sd::DrawDocShell &rDocShell)
Definition: sdcgmfilter.cxx:40
virtual ~SdCGMFilter() override
Definition: sdcgmfilter.cxx:45
static void Init()
Definition: sddll.cxx:218
void CreateFirstPages(SdDrawDocument const *pRefDocument=nullptr)
if the document does not contain at least one handout, one slide and one notes page with at least one...
Definition: drawdoc2.cxx:493
void StopWorkStartupDelay()
Definition: drawdoc2.cxx:932
SdPage * GetMasterSdPage(sal_uInt16 nPgNum, PageKind ePgKind)
Definition: drawdoc2.cxx:217
SfxMedium & mrMedium
Definition: sdfilter.hxx:52
css::uno::Reference< css::task::XStatusIndicator > mxStatusIndicator
Definition: sdfilter.hxx:50
css::uno::Reference< css::frame::XModel > mxModel
Definition: sdfilter.hxx:49
void CreateStatusIndicator()
Definition: sdfilter.cxx:53
SdDrawDocument & mrDocument
Definition: sdfilter.hxx:54
sal_uInt16 GetPageCount() const
void PutItem(const SfxPoolItem &rItem)
SdrPageProperties & getSdrPageProperties()
const INetURLObject & GetURLObject() const
static std::unique_ptr< SvStream > CreateStream(const OUString &rFileName, StreamMode eOpenMode, css::uno::Reference< css::awt::XWindow > xParentWin=nullptr)
SAL_DLLPUBLIC_EXPORT bool TestImportCGM(SvStream &rStream)
Definition: sdcgmfilter.cxx:93
unsigned char sal_uInt8