tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sd / source / filter / cgm / sdcgmfilter.cxx
blob1a4ba2019177ff98102fdb19c09f5e5f5cbdd780
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <memory>
21 #include <filter/importcgm.hxx>
22 #include <tools/urlobj.hxx>
23 #include <unotools/ucbstreamhelper.hxx>
24 #include <sfx2/docfile.hxx>
25 #include <svx/xflclit.hxx>
26 #include <svx/xfillit0.hxx>
28 #include <sddll.hxx>
29 #include <sdpage.hxx>
30 #include <drawdoc.hxx>
31 #include <sdcgmfilter.hxx>
33 #include <DrawDocShell.hxx>
35 using namespace ::com::sun::star;
36 using namespace ::com::sun::star::uno;
37 using namespace ::com::sun::star::task;
39 SdCGMFilter::SdCGMFilter( SfxMedium& rMedium, ::sd::DrawDocShell& rDocShell ) :
40 SdFilter( rMedium, rDocShell )
44 SdCGMFilter::~SdCGMFilter()
48 bool SdCGMFilter::Import()
50 bool bRet = false;
52 if (mxModel.is())
54 OUString aFileURL( mrMedium.GetURLObject().GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
55 sal_uInt32 nRetValue;
57 if( mrDocument.GetPageCount() == 0 )
58 mrDocument.CreateFirstPages();
60 CreateStatusIndicator();
61 std::unique_ptr<SvStream> xIn(::utl::UcbStreamHelper::CreateStream(aFileURL, StreamMode::READ));
62 nRetValue = xIn ? ImportCGM(*xIn, mxModel, mxStatusIndicator) : 0;
64 if( nRetValue )
66 bRet = true;
68 if( ( nRetValue &~0xff000000 ) != 0xffffff ) // maybe the backgroundcolor is already white
69 { // so we must not set a master page
70 mrDocument.StopWorkStartupDelay();
71 SdPage* pSdPage = mrDocument.GetMasterSdPage(0, PageKind::Standard);
73 if(pSdPage)
75 // set PageFill to given color
76 const Color aColor(static_cast<sal_uInt8>(nRetValue >> 16), static_cast<sal_uInt8>(nRetValue >> 8), static_cast<sal_uInt8>(nRetValue >> 16));
77 pSdPage->getSdrPageProperties().PutItem(XFillColorItem(OUString(), aColor));
78 pSdPage->getSdrPageProperties().PutItem(XFillStyleItem(drawing::FillStyle_SOLID));
83 return bRet;
86 bool SdCGMFilter::Export()
88 // No ExportCGM function exists(!)
89 return false;
92 extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportCGM(SvStream &rStream)
94 SdDLL::Init();
96 ::sd::DrawDocShellRef xDocShRef = new ::sd::DrawDocShell(SfxObjectCreateMode::EMBEDDED, false, DocumentType::Impress);
98 xDocShRef->GetDoc()->EnableUndo(false);
99 bool bRet = ImportCGM(rStream, xDocShRef->GetModel(), css::uno::Reference<css::task::XStatusIndicator>()) == 0;
101 xDocShRef->DoClose();
103 return bRet;
106 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */