LCOV - code coverage report
Current view: top level - svtools/source/contnr - DocumentInfoPreview.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 69 0.0 %
Date: 2012-08-25 Functions: 0 9 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 248 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "sal/config.h"
      30                 :            : 
      31                 :            : #include "com/sun/star/beans/XPropertySet.hpp"
      32                 :            : #include "com/sun/star/document/XDocumentProperties.hpp"
      33                 :            : #include "com/sun/star/script/Converter.hpp"
      34                 :            : #include "com/sun/star/script/XTypeConverter.hpp"
      35                 :            : #include "comphelper/processfactory.hxx"
      36                 :            : #include "comphelper/string.hxx"
      37                 :            : #include "rtl/oustringostreaminserter.hxx"
      38                 :            : #include "svl/inettype.hxx"
      39                 :            : #include "svtools/DocumentInfoPreview.hxx"
      40                 :            : #include "svtools/imagemgr.hxx"
      41                 :            : #include "vcl/txtattr.hxx"
      42                 :            : #include "tools/datetime.hxx"
      43                 :            : #include "tools/urlobj.hxx"
      44                 :            : #include "unotools/pathoptions.hxx"
      45                 :            : #include "unotools/ucbhelper.hxx"
      46                 :            : 
      47                 :            : #include "fileview.hxx"
      48                 :            : #include "templwin.hrc"
      49                 :            : #include "templwin.hxx"
      50                 :            : 
      51                 :            : namespace svtools {
      52                 :            : 
      53                 :            : namespace {
      54                 :            : 
      55                 :            : namespace css = com::sun::star;
      56                 :            : 
      57                 :            : }
      58                 :            : 
      59                 :          0 : ODocumentInfoPreview::ODocumentInfoPreview(Window * pParent, WinBits nBits):
      60                 :            :     Window(pParent, WB_DIALOGCONTROL), m_pEditWin(this, nBits),
      61         [ #  # ]:          0 :     m_pInfoTable(new SvtDocInfoTable_Impl),
      62 [ #  # ][ #  # ]:          0 :     m_aLocale(SvtPathOptions().GetLocale()) // detect application language
         [ #  # ][ #  # ]
                 [ #  # ]
      63                 :            : {
      64         [ #  # ]:          0 :     m_pEditWin.SetLeftMargin(10);
      65         [ #  # ]:          0 :     m_pEditWin.Show();
      66         [ #  # ]:          0 :     m_pEditWin.EnableCursor(false);
      67                 :          0 : }
      68                 :            : 
      69 [ #  # ][ #  # ]:          0 : ODocumentInfoPreview::~ODocumentInfoPreview() {}
                 [ #  # ]
      70                 :            : 
      71                 :          0 : void ODocumentInfoPreview::Resize() {
      72         [ #  # ]:          0 :     m_pEditWin.SetPosSizePixel(Point(0, 0), GetOutputSize());
      73                 :          0 : }
      74                 :            : 
      75                 :          0 : void ODocumentInfoPreview::clear() {
      76 [ #  # ][ #  # ]:          0 :     m_pEditWin.SetText(rtl::OUString());
                 [ #  # ]
      77                 :          0 : }
      78                 :            : 
      79                 :          0 : void ODocumentInfoPreview::fill(
      80                 :            :     css::uno::Reference< css::document::XDocumentProperties > const & xDocProps,
      81                 :            :     rtl::OUString const & rURL)
      82                 :            : {
      83                 :            :     assert(xDocProps.is());
      84                 :            : 
      85         [ #  # ]:          0 :     m_pEditWin.SetAutoScroll(false);
      86                 :            : 
      87 [ #  # ][ #  # ]:          0 :     insertNonempty(DI_TITLE, xDocProps->getTitle());
                 [ #  # ]
      88 [ #  # ][ #  # ]:          0 :     insertNonempty(DI_FROM, xDocProps->getAuthor());
                 [ #  # ]
      89 [ #  # ][ #  # ]:          0 :     insertDateTime(DI_DATE, xDocProps->getCreationDate());
                 [ #  # ]
      90 [ #  # ][ #  # ]:          0 :     insertNonempty(DI_MODIFIEDBY, xDocProps->getModifiedBy());
                 [ #  # ]
      91 [ #  # ][ #  # ]:          0 :     insertDateTime(DI_MODIFIEDDATE, xDocProps->getModificationDate());
                 [ #  # ]
      92 [ #  # ][ #  # ]:          0 :     insertNonempty(DI_PRINTBY, xDocProps->getPrintedBy());
                 [ #  # ]
      93 [ #  # ][ #  # ]:          0 :     insertDateTime(DI_PRINTDATE, xDocProps->getPrintDate());
                 [ #  # ]
      94 [ #  # ][ #  # ]:          0 :     insertNonempty(DI_THEME, xDocProps->getSubject());
                 [ #  # ]
      95                 :            :     insertNonempty(
      96                 :            :         DI_KEYWORDS,
      97 [ #  # ][ #  # ]:          0 :         comphelper::string::convertCommaSeparated(xDocProps->getKeywords()));
         [ #  # ][ #  # ]
                 [ #  # ]
      98 [ #  # ][ #  # ]:          0 :     insertNonempty(DI_DESCRIPTION, xDocProps->getDescription());
                 [ #  # ]
      99         [ #  # ]:          0 :     if (!rURL.isEmpty()) {
     100                 :            :         insertNonempty(
     101 [ #  # ][ #  # ]:          0 :             DI_SIZE, CreateExactSizeText(utl::UCBContentHelper::GetSize(rURL)));
                 [ #  # ]
     102 [ #  # ][ #  # ]:          0 :         INetContentType eTypeID = INetContentTypes::GetContentTypeFromURL(rURL);
                 [ #  # ]
     103                 :            :         insertNonempty(
     104                 :            :             DI_MIMETYPE,
     105                 :            :             (eTypeID == CONTENT_TYPE_APP_OCTSTREAM
     106                 :            :              ? SvFileInformationManager::GetDescription(INetURLObject(rURL))
     107 [ #  # ][ #  # ]:          0 :              : INetContentTypes::GetPresentation(eTypeID, m_aLocale)));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     108                 :            :     }
     109                 :            : 
     110                 :            :     // User-defined (custom) properties:
     111                 :            :     css::uno::Reference< css::beans::XPropertySet > user(
     112 [ #  # ][ #  # ]:          0 :         xDocProps->getUserDefinedProperties(), css::uno::UNO_QUERY_THROW);
                 [ #  # ]
     113                 :            :     css::uno::Reference< css::beans::XPropertySetInfo > info(
     114 [ #  # ][ #  # ]:          0 :         user->getPropertySetInfo());
     115 [ #  # ][ #  # ]:          0 :     css::uno::Sequence< css::beans::Property > props(info->getProperties());
     116         [ #  # ]:          0 :     for (sal_Int32 i = 0; i < props.getLength(); ++i) {
     117         [ #  # ]:          0 :         rtl::OUString name(props[i].Name);
     118 [ #  # ][ #  # ]:          0 :         css::uno::Any aAny(user->getPropertyValue(name));
     119                 :            :         css::uno::Reference< css::script::XTypeConverter > conv(
     120                 :            :             css::script::Converter::create(
     121 [ #  # ][ #  # ]:          0 :                 comphelper::getProcessComponentContext()));
     122                 :          0 :         rtl::OUString value;
     123                 :            :         try {
     124         [ #  # ]:          0 :             value = conv->convertToSimpleType(aAny, css::uno::TypeClass_STRING).
     125 [ #  # ][ #  # ]:          0 :                 get< rtl::OUString >();
                 [ #  # ]
     126         [ #  # ]:          0 :         } catch (css::script::CannotConvertException & e) {
     127                 :            :             SAL_INFO("svtools", "ignored CannotConvertException " << e.Message);
     128                 :            :         }
     129         [ #  # ]:          0 :         if (!value.isEmpty()) {
     130         [ #  # ]:          0 :             insertEntry(name, value);
     131                 :            :         }
     132                 :          0 :     }
     133                 :            : 
     134         [ #  # ]:          0 :     m_pEditWin.SetSelection(Selection(0, 0));
     135 [ #  # ][ #  # ]:          0 :     m_pEditWin.SetAutoScroll(true);
     136                 :          0 : }
     137                 :            : 
     138                 :          0 : void ODocumentInfoPreview::insertEntry(
     139                 :            :     rtl::OUString const & title, rtl::OUString const & value)
     140                 :            : {
     141 [ #  # ][ #  # ]:          0 :     if (m_pEditWin.GetText().Len() != 0) {
                 [ #  # ]
     142 [ #  # ][ #  # ]:          0 :         m_pEditWin.InsertText(rtl::OUString("\n\n"));
                 [ #  # ]
     143                 :            :     }
     144                 :          0 :     rtl::OUString caption(title + rtl::OUString(":\n"));
     145 [ #  # ][ #  # ]:          0 :     m_pEditWin.InsertText(caption);
                 [ #  # ]
     146                 :            :     m_pEditWin.SetAttrib(
     147         [ #  # ]:          0 :         TextAttribFontWeight(WEIGHT_BOLD), m_pEditWin.GetParagraphCount() - 2,
     148 [ #  # ][ #  # ]:          0 :         0, caption.getLength() - 1);
                 [ #  # ]
     149 [ #  # ][ #  # ]:          0 :     m_pEditWin.InsertText(value);
                 [ #  # ]
     150                 :          0 : }
     151                 :            : 
     152                 :          0 : void ODocumentInfoPreview::insertNonempty(long id, rtl::OUString const & value)
     153                 :            : {
     154         [ #  # ]:          0 :     if (!value.isEmpty()) {
     155         [ #  # ]:          0 :         insertEntry(m_pInfoTable->GetString(id), value);
     156                 :            :     }
     157                 :          0 : }
     158                 :            : 
     159                 :          0 : void ODocumentInfoPreview::insertDateTime(
     160                 :            :     long id, css::util::DateTime const & value)
     161                 :            : {
     162                 :            :     DateTime aToolsDT(
     163                 :            :         Date(value.Day, value.Month, value.Year),
     164                 :            :         Time(
     165 [ #  # ][ #  # ]:          0 :             value.Hours, value.Minutes, value.Seconds, value.HundredthSeconds));
     166 [ #  # ][ #  # ]:          0 :     if (aToolsDT.IsValidAndGregorian()) {
     167                 :            :         LocaleDataWrapper aLocaleWrapper(
     168                 :            :             comphelper::getProcessServiceFactory(),
     169 [ #  # ][ #  # ]:          0 :             Application::GetSettings().GetLocale());
         [ #  # ][ #  # ]
     170 [ #  # ][ #  # ]:          0 :         rtl::OUStringBuffer buf(aLocaleWrapper.getDate(aToolsDT));
     171         [ #  # ]:          0 :         buf.appendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
     172 [ #  # ][ #  # ]:          0 :         buf.append(aLocaleWrapper.getTime(aToolsDT));
     173 [ #  # ][ #  # ]:          0 :         insertEntry(m_pInfoTable->GetString(id), buf.makeStringAndClear());
         [ #  # ][ #  # ]
     174                 :            :     }
     175                 :          0 : }
     176                 :            : 
     177                 :            : }
     178                 :            : 
     179                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10